package projet.camping.domaine;

import java.io.Serializable;

import javax.persistence.*;

@Entity
@Table(schema="CAMPING", name="HABITATION")
public class Habitation implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 336531766164055809L;
	public enum Orientation {Horizontal,Vertical};
	public enum TypeHabitation { 
		Mobile_Home { int initialise(){return 5;}},
		Bungalow { int initialise(){return 4;}},
		CampingCar { int initialise(){return 3;}},
		TenteLuxe { int initialise(){return 2;}},
		TenteIgloo { int initialise(){return 1;}},
		;	
		int initialise(){return 0;}
	}

	
	@Id
	@GeneratedValue
	private int id;
	@Column(name="TAILLE",nullable=false)
	private int taille;
	@Column(name="CPTTOUCHE",nullable=false)
	private int cptTouche;
	@Enumerated
	@Column(name="ORIENTATION",nullable=false)
	private Orientation orientation;
	@Column(name="X",nullable=false)
	private int x;
	@Column(name="Y",nullable=false)
	private int y;
	@Enumerated
	@Column(name="TYPE")
	private TypeHabitation type;
	
	
	
	public Habitation() {
		// TODO Auto-generated constructor stub
	}

	public Habitation(TypeHabitation type){
		this.type=type;
		taille = type.initialise();
		this.cptTouche = 0;
		this.orientation = Orientation.Horizontal;
		x=-1;
		y=-1;
	}

	public boolean estTouche(){
		return cptTouche>0;
	}
	public boolean estDetruit(){
		return cptTouche==taille;
	}
	public int getTaille() {
		return taille;
	}
	public void setTaille(int taille) {
		this.taille = taille;
	}
	public int getCptTouche() {
		return cptTouche;
	}
	public void incrCptTouche() {
		this.cptTouche++;
	}
	public Orientation getOrientation() {
		return orientation;
	}
	public boolean isHorizontal(){
		return this.orientation == Orientation.Horizontal;
	}

	public void setCptTouche(int cptTouche) {
		this.cptTouche = cptTouche;
	}

	public void setOrientation(Orientation orientation) {
		this.orientation = orientation;
	}

	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public int getId() {
		return id;
	}
	public TypeHabitation getType(){
		return this.type;
	}
	
}
